import java.util.Scanner;

public class demo01 {
    //数位递增的数
    public static boolean check(int tmp){
        while (tmp>=10) {
            int a = tmp % 10;
            tmp /= 10;
            int b = tmp % 10;
            if (a < b) {
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int count=0;
        for (int i = 1; i <= n; i++) {
            if(check(i)){
                count++;
            }
        }
        System.out.println(count);
    }
}
